

project(stylesheet)

find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)

QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} stylesheet_zh_CN.ts) 
file(GLOB_RECURSE  SRCS CONFIGURE_DEPENDS ./*.cpp)

add_executable(${PROJECT_NAME}
     ${SRCS}
     ${QM_FILES}
     stylesheet.qrc
)

if(WIN32)
	if(MSVC)
		set_target_properties(${PROJECT_NAME} PROPERTIES
			WIN32_EXECUTABLE YES
			LINK_FLAGS "/ENTRY:mainCRTStartup"
		)
	else()
		message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)")
	endif(MSVC)
endif(WIN32)

add_custom_command(TARGET ${PROJECT_NAME}
	POST_BUILD
	COMMAND "${CMAKE_COMMAND}" -E copy
		"${QM_FILES}"
		"$<TARGET_FILE_DIR:stylesheet>/localization/")

target_link_libraries(${PROJECT_NAME} Qt::Widgets)
target_link_libraries(${PROJECT_NAME} swidgets)